package com.oldroid.apps.getit.ui.tablet;

import android.os.Bundle;
import android.support.v4.app.FragmentManager;

import com.oldroid.apps.getit.R;
import com.oldroid.apps.getit.ui.BaseMultiPaneActivity;
import com.oldroid.apps.getit.ui.BookmarkFragment;
import com.oldroid.apps.getit.ui.BrowserFragment;
import com.oldroid.apps.getit.ui.phone.BrowserActivity;

public class BrowserMultiPaneActivity extends BaseMultiPaneActivity{
	private BookmarkFragment mBookmarkFragment;
	private BrowserFragment mBrowserFragment;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.activity_browser);
		final FragmentManager fm = getSupportFragmentManager();
		mBrowserFragment = (BrowserFragment) fm.findFragmentByTag("browser");
		mBookmarkFragment = (BookmarkFragment) fm.findFragmentByTag("shortcut");
		if(mBrowserFragment == null){
			mBrowserFragment = new BrowserFragment();
			fm.beginTransaction().add(R.id.fragment_browser_browser, mBrowserFragment, "browser").commit();
			
		}
		if(mBookmarkFragment == null){
			mBookmarkFragment = new BookmarkFragment(fm,mBrowserFragment);
			fm.beginTransaction().add(R.id.fragment_browser_shortcut, mBookmarkFragment, "shortcut").commit();
		}
	}


	@Override
	protected void onPostCreate(Bundle savedInstanceState) {
		super.onPostCreate(savedInstanceState);
		getActivityHelper().setupSubActivity();
	}


	@Override
	protected FragmentReplaceInfo onSubstituteFragmentForActivityLaunch(
			String activityClassName) {
		if(BrowserActivity.class.getName().equals(activityClassName)){
			return new FragmentReplaceInfo(BrowserActivity.class, "browser", R.id.fragment_browser_browser);
		}
		return null;
	}
	
	
	
	
}
